home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1112 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: gidora.kralizec.net.au!root
  2. From: Ross McKay <rosko@zeta.org.au>
  3. Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3
  4. Subject: Re: Hungarian notation
  5. Date: Tue, 09 Jan 1996 22:47:15 -0800
  6. Organization: Soft Technologies
  7. Message-ID: <30F360F3.68B@zeta.org.au>
  8. References: <30C40F77.53B5@swsbbs.com> <30EF0415.6FE1@tus.ssi1.com> <1996Jan7.045815.8676@ohstpy> <4cpb00$nqk@news.xmission.com> <hawkfish-0801960904580001@blv-pm3-ip24.halcyon.com> <4csj8i$gsa@news.xmission.com>
  9. NNTP-Posting-Host: dialup41.syd1.zeta.org.au
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b3 (Win16; I)
  14.  
  15. Todd Knarr wrote:
  16. > In <hawkfish-0801960904580001@blv-pm3-ip24.halcyon.com>, hawkfish@punchdeck.com (Richard Wesley) writes:
  17. > >I've found it useful to use typedefs for all sorts of things like this.
  18. > >Looping through a FooArray with a FooIndex is much more robust than using
  19. > >a long or something.
  20. > I try to avoid syntactic-saccharine typedefs when possible. There's no
  21. > language-level gain from typedef'ing an int or long to something else
  22. > just for that, and it virtually requires an explosion of variables to
  23. > deal with multiple arrays of different types. 
  24. > [snip]
  25.  
  26. One very good reason to do such a thing is to specify a domain. You may 
  27. decide, on initial analysis, that the domain of some thing is within
  28. the limits of a 16-bit integer. Thus, you may (on some platforms) typedef
  29. a short integer for it, and use the new type instead of short int in all
  30. places where a variable is to be restricted to that particular domain.
  31. If, at some later stage of the development process, you determine that
  32. 32 bits would be more appropriate, you only need to change the typedef
  33. (and perhaps some memory access stuff, especially if using 80x86 ;-)
  34.  
  35. I agree that where the domain is known to always fit within all native
  36. word sizes on all target platforms, an int is appropriate. In all other
  37. cases, however, I would suggest that typedef'ing would be more 
  38. appropriate .
  39.  
  40. > --
  41. > Todd Knarr : tknarr@xmission.com      |  finger for PGP public key
  42. >                                       |  Member, USENET Cabal
  43. > Seriously, I don't want to die just yet.  I don't care how
  44. > good-looking they are, I! don't! want! to! die!"
  45. >                                         -- Megazone ( UF1 )
  46.  
  47. -- 
  48. // --------------------------------------------------------------------- //
  49. // Ross McKay        | email: rosko@zeta.org.au | The opinions expressed //
  50. // Soft Technologies | snail: GPO Box 562,      | are my own, not those  //
  51. // Sydney, Australia |        Sydney 2001, Aus. | of my employers.       //
  52. // --------------------------------------------------------------------- //
  53. //  "Circumcision is no skin off my nose"  (grafitti seen in Ultimo)     //
  54. // --------------------------------------------------------------------- //
  55.